#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200000;
struct node{
    int num;
    int col;//1 red 2 blue
}a[N];
int _,ans;
int n;
int check(int i)
{
    int cnt=0;
    for(int j=1;j<=n;j++)
    {
        if(i&j==i)
        {
            a[j].col=1;
        }
        else{
            a[j].col=2;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i-1;j>=1;j--)
        {
            if(a[i].col==a[j].col)
            {
                if(a[i].num==a[j].num) cnt+=a[i].num;
            }
        }
    }
    //cout<<"i:"<<" "<<i<<" "<<cnt<<endl;
    return cnt;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    //DP?

    cin>>_;
    while(_--)
    {
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i].num;
        if(n<=15)
        {
            //cout<<"hi"<<endl;
            for(int i=1;i<=(1<<n);i++)
            {
                //cout<<(i|0)<<endl;

                ans=max(ans,check(i));
            }
            cout<<ans<<endl;
        }
        else{
            cout<<n/2<<endl;
        }

    }

    return 0;
}
